package cn.shequren.communityPeople.pay.utils;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;

import com.jz.community.basecomm.utils.Preconditions;

import cn.shequren.communityPeople.pay.activity.CommUnityPayActivity;
import cn.shequren.communityPeople.pay.constants.CommUnityPayConstants;

/**
 * Created by Tony.Fan on 2018/3/16 10:56
 */
public class CommUnityPayUtil {
    /**
     * 去支付
     *
     * @param activity
     * @param requestCode
     * @param payMethod
     * @param payMedium
     * @param payInfo
     */
    public static void goPay(Activity activity, int requestCode, String payMethod,
                             String payMedium, String payInfo) {
        if (TextUtils.isEmpty(payInfo)) {
            return;
        }
        Intent intent = new Intent();
        intent.setClass(activity, CommUnityPayActivity.class);
        intent.putExtra("PAY_METHOD", payMethod);
        intent.putExtra("PAY_MEDIUM", payMedium);
        intent.putExtra("PAY_INFO", payInfo);

        activity.startActivityForResult(intent, requestCode);
    }

    /**
     * 是否支持的支付
     *
     * @param payMethod
     * @param payInfo
     * @return
     */
    public static boolean isSurportPay(String payMethod, String payInfo) {

        if (Preconditions.isNullOrEmpty(payInfo) || Preconditions.isNullOrEmpty(payMethod)) {
            return false;
        }
        for (String surportPay : CommUnityPayConstants.SURPORT_PAY_METHOD_LIST) {
            if (surportPay.equalsIgnoreCase(payMethod)) {
                return true;
            }
        }
        return false;
    }
}
